#!/bin/bash

basedir=`pwd|tr -d '\n'`

component=wcsite
port=80

deploydir=${basedir}/deployment/${component}

htmldir=${basedir}/src/html/${component}
cssdir=${basedir}/src/css/${component}
jsdir=${basedir}/src/js/${component}
pythondir=${basedir}/src/python/${component}

case $1 in
	deploy)
	echo "deploy the wikicast site"
	mkdir -p ${deploydir}
	mkdir -p ${deploydir}/css
	mkdir -p ${deploydir}/js
	
	cp -r ${htmldir}/* ${deploydir}/
	cp -r ${cssdir}/* ${deploydir}/css/
	cp -r ${jsdir}/* ${deploydir}/js/
	cp -r ${htmldir}/* ${deploydir}/
	cp -r ${pythondir}/* ${deploydir}/
	
	echo "sync db ..."
	cd ${deploydir}
	python manage.py syncdb
	echo "deploy ok!"
	cd ${basedir}
	exit 1
	;;
	start)
	echo "start the wikicast site"
	cd ${deploydir}
	python manage.py runserver ${port} >> runtime.log &
	echo "django site is running with port - ${port}"
	cd ${basedir}
	exit 2
	;;
	
	stop)
	#stop wikicast
	echo "stop the wikicast site"
	;;
esac